from ocms.eventmanager.models import *
from django.contrib import admin

class EventAdmin(admin.ModelAdmin):
    actions = ['archive_events', 'approve_events', 'deny_events', 'delete_events']
    list_display = ('Name', 'content_type', 'Start_Date', 'End_Date', 'Location', 'date_created', 'approval_status', 'event_status')
    list_filter = ['event_status','Start_Date', 'date_created', 'approval_status']
    date_hierarchy = 'Start_Date'
    search_fields = ['Name']

    def archive_events(EventAdmin, request, queryset):
        for event in queryset:
            event.archive()
            
    def delete_events(EventAdmin, request, queryset):
        for event in queryset:
            event.delete()
        
    def approve_events(EventAdmin, request, queryset):
        for event in queryset:
            event.approve()
            
    def deny_events(EventAdmin, request, queryset):
        for event in queryset:
            event.deny()
                
    archive_events.short_description = "Archive selected events"
    approve_events.short_description = "Approve selected events"
    deny_events.short_description = "Deny selected events"
    delete_events.short_description = "Delete selected events (flag deleted)"

admin.site.register(EventType)
admin.site.register(EventSupportItem)
admin.site.register(Event, EventAdmin)
